const web = require("../../module/web"), loger = require("../../module/loger");
let cfg = null;

module.exports.run = (k)=>{
	if(k) cfg = require("./"+k);
	web.run((w)=>{
		if(w.window.location.href.indexOf(cfg.uk) > 0){ //进入了游戏界面
			
		}else{
			w.window.location.href = cfg.url;
		}
	}, (w)=>{
		loger.info("send loaded");
		if(w.window.location.href.indexOf(cfg.uk) > 0){
			let pl = w.window.document.getElementById("cmt-type-list");
			if(pl){
				let tp = pl.getElementsByTagName("type");
				for(let i=0;i<tp.length;i++){
					if(tp[i].id == "type1"){
						tp[i].click();
					}
				}
				w.window.document.getElementById("review-content").value = cfg.plist[parseInt(Math.random()*cfg.plist.length)];
				w.window.document.getElementById("btn-do-review").click();
				global.sdObj.end = 0;
				return true;
			}
		}else{
			w.window.location.href = cfg.url;
		}
	})
}